﻿<!DOCTYPE html>
<html ng-app="app">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>@ViewBag.Title - My ASP.NET Application</title>
    </head>
    <body>

        <div ng-view></div>
        <div animated-view></div>

        @RenderBody()

        <script src="~/Scripts/angular.min.js"></script>

        <script src="~/Scripts/angular-route.js"></script>
        <script src="~/Scripts/angular-animate.min.js"></script>

        <script>
         
            var app = angular.module("app", ['ngRoute', 'ngAnimate']);

            
            app.config(function ($routeProvider) {
                $routeProvider
                    .when('/:param', {
                                   
                                         controller: "SimpleController",
                                         templateUrl: "Partials/View.html"
                          })
                    .when('/', {

                                   controller: "SimpleController",
                                   templateUrl: "Partials/View.html"
                          })
                    .otherwise({ redirectTo: '/' });
            });
            
            
            var controllers = {}

            controllers.SimpleController = function ($scope, $routeParams, MyService) {
                unit();

                function unit() {
                    $scope.customers = MyService.getCustomers();

                    if ($routeParams.param !== "") {
                        $scope.message = $routeParams.param
                    }
                }
            };
            
            app.controller(controllers);
            
            
            app.service("MyService", function () {
                this.getCustomers = function () {
                    var customers = [
                        { name: "John", city: 'Lovech' },
                        { name: "Jose", city: 'Pleven' },
                        { name: "Horka", city: 'Tihyana' }
                    ];
            
                    return customers;
                }
            })
            
            
        </script>
        
    </body>
</html>

            